<%--各个区域的用户列表页面--%>
<%@ page import="pojo.User" %>
<%@ page import="dao.impl.UserDaoImpl" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="pojo.Addpower" %>
<%@ page import="dao.AddpowerDao" %>
<%@ page import="dao.impl.AddpowerDaoImpl" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<style>
    .users{
        margin: auto;
        margin-left: 200px;
    }
    .back{
        margin-left: 770px;
    }
    .page{
        margin-left: 420px;
    }
    .active{
        border:1px solid lightskyblue;
        background-color:lightskyblue;
        width:12px;
        height:10px;
    }
    .nonactive{
        border:1px solid black;
        width:12px;
        height:10px;
    }
</style>
<body>
<%
    int mid= Integer.parseInt(request.getParameter("mid"));
    String type= (String) session.getAttribute("type");
    request.setAttribute("type",type);
    request.getParameter("page");
    User userLogin= (User) session.getAttribute("userLogin");
    AddpowerDao addpowerDao=new AddpowerDaoImpl();
    ArrayList<Addpower> powers=addpowerDao.findAreaUserPower(mid);
    request.setAttribute("powers",powers);
    int flag=0;
    request.setAttribute("flag",flag);
    request.setAttribute("mid",mid);
//    ArrayList<User> areausers=new ArrayList<>();
//    ImplementUser implementUser=new ImplementUser();
//    areausers=implementUser.areaUsers(type);
//    request.setAttribute("areausers",areausers);
%>
<h3 align="center">用户</h3>
<a href="${pageContext.request.contextPath}/pageServlet?action=allNotesPage" type="submit" class="back">返回</a>
<table class="users" border="1" width="500" align="center">
    <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>电话</th>
        <th>操作</th>
    </tr>

    <c:forEach items="${page.list}" var="user" varStatus="s">
        <tr>
            <td>${user.usename}</td>
            <td>${user.age}</td>
            <td>${user.gender}</td>
            <td>${user.telephone}</td>

<c:forEach items="${powers}" var="addpower" varStatus="s">
    <c:if test="${user.uid==addpower.uid}">
        <input type="hidden" value="${flag=1}">
    </c:if>
</c:forEach>

            <c:if test="${flag==1}">
            <td><a href="${pageContext.request.contextPath}/noteServlet?action=deleteUserAddpower&uid=${user.uid}&mid=${mid}" type="submit">取消禁止</a></td>

        </c:if>
            <c:if test="${flag==0}">
                <td id="if"><a href="${pageContext.request.contextPath}/userServlet?action=addUserAddpower&uid=${user.uid}&mid=${mid}" type="submit" >禁止发布</a></td>
            </c:if>
        </tr>
    </c:forEach>
</table>

<div class="page">
    <nav aria-label="page navigation">
        <ul class="pagination">
            <c:if test="${page.currentPage==1}">
    <span aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
    </span>
            </c:if>
            <c:if test="${page.currentPage!=1}">
                <a href="${pageContext.request.contextPath}/pageServlet?action=areaUsersPage&mid=${userLogin.mid}&currentPage=${page.currentPage-1}&rows=5" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </c:if>
            <c:forEach begin="1" end="${page.totalPage}" var="i">

                <c:if test="${page.currentPage==i}">
                    <a href="${pageContext.request.contextPath}/pageServlet?action=areaUsersPage&mid=${userLogin.mid}&currentPage=${i}&rows=5"  class="active">${i}</a>
                </c:if>
                <c:if test="${page.currentPage!=i}">
                    <a href="${pageContext.request.contextPath}/pageServlet?action=areaUsersPage&mid=${userLogin.mid}&currentPage=${i}&rows=5" class="nonactive">${i}</a>
                </c:if>
            </c:forEach>
            <c:if test="${page.currentPage!=page.totalPage&&page.totalPage!=0}">
                <a href="${pageContext.request.contextPath}/pageServlet?action=areaUsersPage&mid=${userLogin.mid}&currentPage=${page.currentPage+1}&rows=5" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </c:if>
            <c:if test="${page.currentPage==page.totalPage||page.totalPage==0}">
                <span aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </span>
            </c:if>
            <span style="font-size: 20px;margin-left: 5px;">
                共${page.total}条笔记，共${page.totalPage}页
            </span>
        </ul>
    </nav>
</div>
</body>
</html>
